app.controller('brandController',function($scope,$controller,brandService){

	//继承
	$controller('baseController',{$scope:$scope});

	//分页
	$scope.findPage=function(page,rows){	
		brandService.findPage(page,rows).success(
				function(response){
					$scope.list=response.rows;	
					$scope.paginationConf.totalItems=response.total;//更新总记录数
				}			
		);
	}

	//添加
	$scope.save = function(){
		var serv = "";
		if($scope.entity.id != null){
			serv = brandService.edit($scope.entity);
		}else{
			serv = brandService.save($scope.entity);
		}
		serv.success(
			function(response){
				if(response.success){
					$scope.reloadList();
				}else{
					alert(response.message);
				}
			}
		);
	}
	
	//编辑
	$scope.findOne = function(id){
		brandService.findOne(id).success(
			function(response){
				$scope.entity = response;
			}
		);
	}
	

	// 删除
	$scope.del = function(){
		brandService.del($scope.selectIds).success(
			function(response){
				if(response.success){
					$scope.reloadList();
				}else{
					alert(response.message);
				}
			}
		);
	}
});